home *** CD-ROM | disk | FTP | other *** search
- #!/bin/bash
- # Activate a module, while running LiveCD.
- # Include it into live directory structure on the fly
- #
- # Author: Tomas M. <http://www.linux-live.org>
-
- if [ "$1" = "-k" ]; then
- CALLED_BY_KDE_HELPER=1
- shift
- fi
-
- if [ -e /usr/bin/kactivate -a "$DISPLAY" -a ! "$CALLED_BY_KDE_HELPER" ]; then
- exec /usr/bin/kactivate "$@" 2>/dev/null
- fi
-
- MODULE=$(readlink -f "$1")
-
- if [ "$MODULE" = "" -o ! -e "$MODULE" -o -d "$MODULE" ]; then
- echo
- echo "Activate a module on the fly while running Linux Live"
- echo "Usage: $0 module.lzm"
- exit 1
- fi
-
- if [ "$(echo $MODULE | fgrep -i .lzm)" = "" ]; then
- echo
- echo "$(basename $MODULE): Module must end with .lzm"
- exit 2
- fi
-
- PATH=.:$(dirname $0):/usr/lib:$PATH
- . liblinuxlive || exit 3
-
- allow_only_root
- IMAGES=/mnt/live/memory/images
- MODULES=/mnt/live/memory/modules
-
- # are we even using union?
- if [ "$(grep '^aufs / ' /proc/mounts)" = "" ]; then
- echo "not in the live mode, can't continue. Try lzm2dir $MODULE /"
- exit 4
- fi
-
- mkdir -p "$MODULES"
-
- # Test whether the module file is stored in union
- # if yes, then we must move it somewhere else (to RAM) else it can't be added
- if [ -e "/mnt/live/memory/changes/$(readlink -f "$MODULE")" ]; then
- echo "module file is stored inside the union, moving to $MODULES first..."
- TARGET="$MODULES/$(basename "$MODULE")"
- mv "$MODULE" "$TARGET"
- if [ $? -ne 0 ]; then
- echo "error copying module to memory, not enough free RAM? try df" >&2
- rm "$TARGET"
- exit 6
- fi
- MODULE="$TARGET"
- fi
-
- MOD=$(union_insert_module / "$MODULE" $IMAGES)
- if [ $? -ne 0 ]; then echo "error inserting module to live filesystem" >&2; exit 3; fi
-
- # All executables (but symlinks) in /etc/rc.d/init.d/ from this module will be started
- # with two arguments: "start" "activate".
- # This is done only by the 'activate' script, not in the case when the module is loaded
- # during OS startup (in that case, your distro is responsible for execution)
- #
- # For compatibility, /etc/init.d is also examined, but it's not recommended for you to put your startup scripts
- # there in your module
-
- MOD="$IMAGES/$(basename $MOD)"
-
- find_n_run_scripts $MOD start activate
-
- # update ld cache if new ld.so.conf/cache exists in the module
- if [ -e "$MOD/etc/ld.so.conf" -o -e "$MOD/etc/ld.so.cache" ]; then
- echo "Module contains ld.so.conf or ld.so.cache, updating libs cache..."
- /sbin/ldconfig
- fi
-